using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using BLL;
using BLL.Impl;

namespace WebUI.Cost
{
    public partial class CarriersDispatch : BasicPage
    {
        private ICarriersManager carriersManager;
        private ICostManager costManager;
        protected void Page_Load(object sender, EventArgs e)
        {
            costManager = BLLFactory.CreateCostManager();
            carriersManager = BLLFactory.CreateCarriersManager();
            if (!IsPostBack)
            {
                Display();
            }
        }

        private void Display()
        {
            this.gvwCarriersList.DataSource = carriersManager.ListCarriers();
            this.gvwCarriersList.DataKeyNames = new string[] { "CarriersSN" };
            this.gvwCarriersList.DataBind();
        }

        protected void gvwCarriersList_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            int carriersSn = Int32.Parse(this.gvwCarriersList.DataKeys[e.NewSelectedIndex].Value.ToString());
            Response.Redirect("~/Cost/Cost_Modify.aspx?CarriersSN="+carriersSn);
        }

        protected void gvwCarriersList_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this.gvwCarriersList.PageIndex = e.NewPageIndex;
            Display();
        }
    }
}
